<?php
/*
	插件概览
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$plugin_name = $_RQ['basicname'] ? $_RQ['basicname'] : '';
if($_RQ['op']=='get'){
	//显示统计数据
	$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
	$mounthtime =  mktime(0,0,0,date('m'),1,date('Y'));
	$order['all']=pdo_count('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>array(1,2,3,5,6)));
	$order['day']=pdo_count('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>array(1,2,3,5,6),'createtime >'=>$daytime));
	$money['all']=pdo_getsum('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'ispay'=>1),'price');
	$money['day']=pdo_getsum('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'ispay'=>1,'createtime >'=>$daytime),'price');
	
	$order['table']=pdo_count('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>3,'buytype'=>1));
	$order['out']=pdo_count('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>3,'buytype'=>2));
	$order['self']=pdo_count('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>3,'buytype'=>3));
	$order['yuyue']=pdo_count('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>3,'buytype'=>4));
	
	$money['table']=pdo_count('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>3,'buytype'=>1));
	$money['out']=pdo_count('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>3,'buytype'=>2));
	$money['self']=pdo_count('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>3,'buytype'=>3));
	$money['yuyue']=pdo_count('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>3,'buytype'=>4));
		
	$member['day'] = pdo_count('jy_weishop_member',array('uniacid'=>$_SESSION['uniacid'],'createtime >'=>$daytime));
	$member['all'] = pdo_count('jy_weishop_member',array('uniacid'=>$_SESSION['uniacid']));
	$access['day'] = pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'this'=>2,'plugin'=>'jy_weishop','createtime >'=>$daytime));
	$access['app_day'] = pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'this'=>2,'plugin'=>'jy_weishop','os'=>1,'createtime >'=>$daytime));
	$access['h5_day'] = pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'plugin'=>'jy_weishop','os'=>2,'createtime >'=>$daytime));
	$access['all'] = pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'plugin'=>'jy_weishop'));
	//月份
	for($i=0;$i<12;$i++){
			if($i==0){
				$yuestart = mktime(0,0,0,date('m'),1,date('Y'));
				$yueend = time();
				
			}else{
				$yuestart = mktime(0,0,0,date('m')-$i,1,date('Y'));
				$yueend = mktime(0,0,0,date('m')-$i+1,1,date('Y'));
			}
			$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>array(1,2,3,5,6));
			$params['createtime between']=array($yuestart,$yueend);
			$month12[] = date('Y-m',strtotime('-'.$i.' month'));
			//$monthaccess[]=pdo_count('core_access_log',$params);
			$monthorder[]=pdo_count('jy_weishop_order',$params);
			$monthfee=pdo_getsum('jy_weishop_order',$params,'price');
			$monthmoney[]=intval($monthfee);
			//$monthcredit2[]=pdo_getsum('core_members',$params,'credit2');
	}
	$return['monthorder']=array_reverse($monthorder);
	$return['monthmoney']=array_reverse($monthmoney);
	$return['month12']=array_reverse($month12);
	$return['order']=$order;
	$return['money']=$money;
	$return['access']=$access;
	//计算IP次数：
	$accessip['day'] = pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'plugin'=>'jy_weishop','is_ip'=>1,'createtime >'=>$daytime));
	$accessip['day_rate'] = price(100*$order['day']/$accessip['day']);
	$accessip['all'] = pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'plugin'=>'jy_weishop','is_ip'=>1));
	$accessip['all_rate'] = price(100*$order['all']/$accessip['all']);
	$accessip['app'] = pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'plugin'=>'jy_weishop','os'=>1,'is_ip'=>1));
	$accessip['app_rate'] = price(100*$order['all']/$accessip['app']);
	$accessip['app_day'] = pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'plugin'=>'jy_weishop','os'=>1,'is_ip'=>1,'createtime >'=>$daytime));
	$accessip['app_day_rate'] = price(100*$order['day']/$accessip['app_day']);
	$accessip['h5'] = pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'plugin'=>'jy_weishop','os'=>2,'is_ip'=>1));
	$accessip['h5_rate'] = price(100*$order['all']/$accessip['h5']);
	$accessip['h5_day'] = pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'plugin'=>'jy_weishop','os'=>2,'is_ip'=>1,'createtime >'=>$daytime));
	$accessip['h5_day_rate'] = price(100*$order['day']/$accessip['h5_day']);
	$return['accessip']=$accessip;
	//成交率
	$dayorder=pdo_count('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'createtime >'=>$daytime));
	$allorder=pdo_count('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid']));
	$rate['order']=price(100*$order['day']/$dayorder);
	$rate['user']=price(100*$order['day']/$accessip['day']);
	$rate['userorder']=price(100*$dayorder/$accessip['day']);
	$rate['access']=price(100*$order['day']/$access['day']);
	$rate['all_order']=price(100*$order['all']/$allorder);
	$rate['all_user']=price(100*$order['all']/$accessip['all']);
	$rate['all_access']=price(100*$order['all']/$access['all']);
	$return['rate']=$rate;
	if($_RQ['headerno']){
		set_html('header','common/header-no');
	}
	$return['screenurl']=manage_url('jy_echarts/index//headerno=1');
	exi($return);
}